package com.csproj.siiat.base.common.exception;

/**
 * checked Exception的子类，系统中所有checked类都要继承该类。
 *
 * @author liuzhaofeng
 * @version 2017/4/6
 */
public class BaseAppException extends RuntimeException {

    private static final long serialVersionUID = 8343048459443313229L;
    private Boolean success;


    /**
     *
     * @param code 错误状态码
     * @param message 错误信息
     * @return
     */
    public BaseAppException(Integer code, String message){
        super(message);
        if(code ==200){
            setSuccess(true);
        }else{
            setSuccess(false);
        }
    }

    /**
     *
     * @param success 错误状态码
     * @param message 错误信息
     * @return
     */
    public BaseAppException(Boolean success, String message){
        super(message);
        setSuccess(success);

    }

    public static BaseAppException createBaseAppException(Boolean success, String message){
    	BaseAppException baseAppException = new BaseAppException(success, message);
        return baseAppException;
    }

    public static BaseAppException createBaseAppException(String message){
        BaseAppException baseAppException = new BaseAppException(true, message);
        return baseAppException;
    }

    public Boolean getSuccess() {
        return success;
    }

    private void setSuccess(Boolean success) {
        this.success = success;
    }
}
